#ifndef DBUSLOG_HPP
#define DBUSLOG_HPP

#include <QObject>
#include <QTextStream>
#include <QtDBus>
struct DVariant;
class DbusLog;

QString getLogPath();

DbusLog &runLog(const QString &filename = "");
DbusLog &signalLog(QString filename="");

class DbusLog : public QObject
{
    Q_OBJECT
public:
    explicit DbusLog(QObject *parent = nullptr);
    explicit DbusLog(const QString &prefix,const QString &filename="",QObject *parent = nullptr);
    QByteArray data();
    ~DbusLog();
    DbusLog &operator<<(QChar t);
    DbusLog &operator<<(bool t);
    DbusLog &operator<<(char t);
    DbusLog &operator<<(uchar t);
    DbusLog &operator<<(signed short t);
    DbusLog &operator<<(unsigned short t);
    DbusLog &operator<<(signed int t);
    DbusLog &operator<<(unsigned int t);
    DbusLog &operator<<(signed long t);
    DbusLog &operator<<(unsigned long t);
    DbusLog &operator<<(qint64 t);
    DbusLog &operator<<(quint64 t);
    DbusLog &operator<<(float t);
    DbusLog &operator<<(double t);
    DbusLog &operator<<(const char *t);
    DbusLog &operator<<(const QString &t);
    DbusLog &operator<<(const QByteArray &t);
    DbusLog &operator<<(const QDBusMessage &t);
    DbusLog &operator<<(const QDBusArgument &t);
    DbusLog &operator<<(const QVariant &t);
    DbusLog &operator<<(const DVariant &t);
    DbusLog &operator<<(const QDateTime &t);
    DbusLog &operator<<(QTextStreamFunction f);


signals:
    void logNameChange(const QString &path,const QString &prefix , const QString &filename);
public slots:
private:
    bool checkFile();
    QString m_path;
    QString m_prefix;
    QFile *m_file;
    QString m_fileName;
    QByteArray m_message;
};

#endif // DBUSLOG_HPP
